package com.zbaohuang.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zbaohuang.view.CircleImageView;
import com.zbaohuang.xyh.R;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by zbaohuang on 16/4/7.
 */
public class LiuYanBanAdapter extends BaseAdapter {

    private Context context;

    public LiuYanBanAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return 5;
    }

    @Override
    public Object getItem(int i) {
        return "" + i;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder = null;

        if (view == null){
            view = LayoutInflater.from(context).inflate(R.layout.item_liu_yan_ban, viewGroup, false);
            viewHolder = new ViewHolder(view);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder)view.getTag();
        }

        if (i == 0){
            viewHolder.avatarImageView.setImageResource(R.mipmap.woman);
            viewHolder.nameTextView.setText("妈妈");
            viewHolder.timeTextView.setText("2016-04-06 15:10");
            viewHolder.lenghtTextView.setText("20 ''");
        } else if(i == 1){
            viewHolder.avatarImageView.setImageResource(R.mipmap.woman);
            viewHolder.nameTextView.setText("妈妈");
            viewHolder.timeTextView.setText("2016-04-05 18:10");
            viewHolder.lenghtTextView.setText("24 ''");
        } else if(i == 2){
            viewHolder.avatarImageView.setImageResource(R.mipmap.man2);
            viewHolder.nameTextView.setText("岳父");
            viewHolder.timeTextView.setText("2016-04-04 10:10");
            viewHolder.lenghtTextView.setText("15 ''");
        } else if(i == 3){
            viewHolder.avatarImageView.setImageResource(R.mipmap.woman);
            viewHolder.nameTextView.setText("妈妈");
            viewHolder.timeTextView.setText("2016-04-04 08:10");
            viewHolder.lenghtTextView.setText("18 ''");
        } else if(i == 4){
            viewHolder.avatarImageView.setImageResource(R.mipmap.man1);
            viewHolder.nameTextView.setText("爸爸");
            viewHolder.timeTextView.setText("2016-04-03 18:10");
            viewHolder.lenghtTextView.setText("30 ''");
        }


        return view;
    }

    static class ViewHolder {
        @Bind(R.id.avatarImageView)
        CircleImageView avatarImageView;
        @Bind(R.id.nameTextView)
        TextView nameTextView;
        @Bind(R.id.timeTextView)
        TextView timeTextView;
        @Bind(R.id.lenghtTextView)
        TextView lenghtTextView;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
